<template>
    <el-dialog title="登录" :visible.sync="dialogFormVisible">
    <el-form >
        <el-form-item label="用户名" :label-width="formLabelWidth">
        <el-input v-model="user.uname" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="用户密码" :label-width="formLabelWidth">
        <el-input v-model="user.password" autocomplete="off"></el-input>
        </el-form-item>
    </el-form>
  <div slot="footer" class="dialog-footer">
    <el-button @click="dialogFormVisible = false">取 消</el-button>
    <el-button type="primary" @click="dl">确 定</el-button>
  </div>
</el-dialog>
</template>
<script>
export default {
    name: 'login',
     data() {
      return {
        dialogFormVisible: true,
          user: {
              uname: '',
              password: ''
          },
        formLabelWidth: '120px'
      };
    },
    methods: {
        //登录方法
        dl() {
		//定义常量保存 url
		const url = "http://localhost:9090/person/login";
		//发送请求
		this.axios
		.get(url, {
				//携带参数
				params: {
					username: this.user.uname,
					password: this.user.password,
				},
		})
		.then((res) => {
			console.log(res);
			//成功就将对话框关闭
			this.dialogFormVisible = false;
		})
		.catch((error) => {
			//出现错误使用ElementUI提供的消息提示
			this.$message.error("对不起! 登录错误!");
		});
	},
    }
}
</script>
<style>

</style>